home *** CD-ROM | disk | FTP | other *** search
/ Micromanía 92 / CDMM92_1.ISO / SOF 2 SDK / sof2sdk-101.msi / _92D6AC311BB48EBA344BBABC89DA6AB0 / _A3D9174127424FC082AAFF8A336DC020 < prev    next >
Encoding:
Text File  |  2002-06-19  |  50.4 KB  |  1,456 lines

  1. // Copyright (C) 2001-2002 Raven Software.
  2. //
  3. // cg_local.h --
  4.  
  5. #include "../game/q_shared.h"
  6. #include "tr_types.h"
  7. #include "../game/bg_public.h"
  8. #include "cg_public.h"
  9. #include "../ghoul2/g2.h"
  10. #include "../ghoul2/G2_gore_shared.h"
  11. #include "../game/inv.h"
  12.  
  13. #undef _SNAPSHOT_EXTRAPOLATION
  14.  
  15. // The entire cgame module is unloaded and reloaded on each level change,
  16. // so there is NO persistant data between levels on the client side.
  17. // If you absolutely need something stored, it can either be kept
  18. // by the server in the server stored userinfos, or stashed in a cvar.
  19.  
  20. #define    FADE_TIME                    200
  21. #define    DAMAGE_DEFLECT_TIME            100
  22. #define    DAMAGE_RETURN_TIME            400
  23. #define DAMAGE_TIME                    500
  24. #define    LAND_DEFLECT_TIME            150
  25. #define    LAND_RETURN_TIME            300
  26. #define    STEP_TIME                    200
  27. #define    DUCK_TIME                    100
  28. #define    PAIN_TWITCH_TIME            200
  29.                                     
  30. // Zoom vars                        
  31. #define MAX_ZOOM_FOV                3.0f
  32. #define ZOOM_OUT_TIME                100.0f
  33.  
  34. #define    MUZZLE_FLASH_TIME            20
  35. #define    MUZZLE_FLASH_EFFECT_TIME    250
  36. #define    SINK_TIME                    1000        // time for fragments to sink into ground before going away
  37.  
  38. #define NUMFLYBYS                    4
  39.                                     
  40. #define    MAX_STEP_CHANGE                32
  41.                                     
  42. #define    CHAR_WIDTH                    32
  43. #define    CHAR_HEIGHT                    48
  44.                                     
  45. #define    CHAT_WIDTH                    80
  46. #define CHAT_HEIGHT                    8
  47.  
  48. #define    NUM_CROSSHAIRS                5
  49.  
  50. #define    DEFAULT_IDENTITY            "mullinsjungle"
  51.  
  52. #define MAX_SOUNDBUFFER                20
  53.  
  54.  
  55. #define    FX_DEPTH_HACK                0x00100000
  56.  
  57. typedef void*    TGhoul2;
  58.  
  59. /*
  60. =================
  61. player entities need to track more information
  62. than any other type of entity.
  63.  
  64. note that not every player entity is a client entity,
  65. because corpses after respawn are outside the normal
  66. client numbering range
  67.  
  68. when changing animation, set animationTime to frameTime + lerping time
  69. The current lerp will finish out, then it will lerp to the new animation
  70. =================
  71. */
  72. typedef struct playerEntity_s
  73. {
  74.     animInfo_t        torso;
  75.     animInfo_t        legs;
  76.  
  77.     int                painTime;
  78.     int                painDirection;        // flip from 0 to 1
  79.     int                lightningFiring;
  80.  
  81.     int                weapon;
  82.     int                weaponModelSpot;
  83.  
  84.     int                spawnCount;            // used to track spawn transitions
  85.  
  86.     vec3_t            ghoulLegsAngles;
  87.     vec3_t            ghoulLowerTorsoAngles;
  88.     vec3_t            ghoulUpperTorsoAngles;
  89.     vec3_t            ghoulHeadAngles;
  90.  
  91. } playerEntity_t;
  92.  
  93. /*
  94. =================
  95. centity_t have a direct corespondence with gentity_t in the game, but
  96. only the entityState_t is directly communicated to the cgame
  97. =================
  98. */
  99. typedef struct centity_s 
  100. {
  101.     entityState_t    currentState;        // from cg.frame
  102.     entityState_t    nextState;            // from cg.nextFrame, if available
  103.     qboolean        interpolate;        // true if next is valid to interpolate to
  104.     qboolean        currentValid;        // true if cg.frame holds this entity
  105.  
  106.     int                muzzleFlashTime;    // move to playerEntity?
  107.     attackType_t    muzzleFlashAttack;    // Which attack mode the muzzle flash was for
  108.     int                previousEvent;
  109.     int                teleportFlag;
  110.  
  111.     int                trailTime;            // so missile trails can handle dropped initial packets
  112.     int                dustTrailTime;        
  113.     int                miscTime;            
  114.                                         
  115.     int                snapShotTime;        // last time this entity was found in a snapshot
  116.                                         
  117.     playerEntity_t    pe;                    
  118.                                         
  119.     int                errorTime;            // decay the error from this time
  120.     vec3_t            errorOrigin;        
  121.     vec3_t            errorAngles;        
  122.                                         
  123.     qboolean        extrapolated;        // false if origin / angles is an interpolation
  124.     vec3_t            rawOrigin;
  125.     vec3_t            rawAngles;
  126.  
  127.     vec3_t            beamEnd;
  128.  
  129.     // exact interpolated position of entity on this frame
  130.     vec3_t            lerpOrigin;
  131.     vec3_t            lerpAngles;
  132.     vec3_t            lerpVelocity;
  133.     float            lerpLeanOffset;
  134.  
  135.     int                ambientSetTime;
  136.  
  137.     void            *ghoul2;
  138.     vec3_t            modelScale;
  139.     float            radius;
  140.     int                boltInfo;
  141.  
  142.     CFxBoltInterface    flashBoltInterface;
  143.     CFxBoltInterface    ejectBoltInterface;
  144.  
  145. } centity_t;
  146.  
  147.  
  148. typedef enum 
  149. {
  150.     LE_FRAGMENT,
  151.     LE_MOVE_SCALE_FADE,
  152.     LE_FALL_SCALE_FADE,
  153.     LE_FADE_RGB,
  154.     LE_SCALE_FADE,
  155.     LE_SHOWREFENTITY,
  156.     LE_LINE,
  157.     LE_GIB
  158.  
  159. } leType_t;
  160.  
  161. typedef enum 
  162. {
  163.     LEF_PUFF_DONT_SCALE = 0x0001,            // do not scale size over time
  164.     LEF_TUMBLE            = 0x0002,            // tumble over time, used for ejecting shells
  165.     LEF_FADE_RGB        = 0x0004,            // explicitly fade
  166.     LEF_NO_RANDOM_ROTATE= 0x0008            // MakeExplosion adds random rotate which could be bad in some cases
  167.  
  168. } leFlag_t;
  169.  
  170. typedef enum 
  171. {
  172.     LEMT_NONE,
  173.     LEMT_BURN,
  174.     LEMT_BLOOD
  175.  
  176. } leMarkType_t;            // fragment local entities can leave marks on walls
  177.  
  178. typedef enum 
  179. {
  180.     LEBS_NONE,
  181.     LEBS_BRASS
  182.  
  183. } leBounceSoundType_t;    // fragment local entities can make sounds on impacts
  184.  
  185. typedef struct localEntity_s 
  186. {
  187.     struct localEntity_s*    prev;
  188.     struct localEntity_s*    next;
  189.  
  190.     leType_t                leType;
  191.     int                        leFlags;
  192.                             
  193.     int                        startTime;
  194.     int                        endTime;
  195.     int                        fadeInTime;
  196.                             
  197.     float                    lifeRate;            // 1.0 / (endTime - startTime)
  198.                             
  199.     trajectory_t            pos;
  200.     trajectory_t            angles;
  201.                             
  202.     float                    bounceFactor;        // 0.0 = no bounce, 1.0 = perfect
  203.                             
  204.     float                    alpha;
  205.     float                    dalpha;
  206.                             
  207.     float                    color[4];
  208.                             
  209.     float                    radius;
  210.                             
  211.     float                    light;
  212.     vec3_t                    lightColor;
  213.  
  214.     leMarkType_t            leMarkType;            // mark to leave on fragment impact
  215.     leBounceSoundType_t        leBounceSoundType;
  216.                             
  217.     float                    zOffset;
  218.                             
  219.     refEntity_t                refEntity;        
  220.  
  221. } localEntity_t;
  222.  
  223. //======================================================================
  224.  
  225.  
  226. typedef struct 
  227. {
  228.     int            client;
  229.     int            score;
  230.     int            kills;
  231.     int            deaths;
  232.     int            ping;
  233.     int            time;
  234.     int            scoreFlags;
  235.     int            team;
  236.     int            teamkillDamage;    // damage inflicted to teammates (0-100)
  237.  
  238. } score_t;
  239.  
  240. // each client has an associated clientInfo_t
  241. // that contains media references necessary to present the
  242. // client model and other color coded effects
  243. // this is regenerated each time a client's configstring changes,
  244. // usually as a result of a userinfo (name, model, etc) change
  245. typedef enum
  246. {
  247.     SOUND_DIE_1 = 0,
  248.     SOUND_DIE_2,
  249.     SOUND_DIE_3,
  250.     SOUND_PAIN_1,
  251.     SOUND_PAIN_2,
  252.     SOUND_PAIN_3,
  253.  
  254.     MAX_CUSTOM_SOUNDS
  255.  
  256. } ECustomSounds;
  257.  
  258. typedef struct 
  259. {
  260.     qboolean        infoValid;
  261.     qboolean        ghost;
  262.  
  263.     char            name[MAX_QPATH];
  264.     team_t            team;
  265.  
  266.     int                botSkill;        // 0 = not bot, 1-5 = bot
  267.  
  268.     vec3_t            color1;
  269.     vec3_t            color2;
  270.  
  271.     int                score;            // updated by score servercmds
  272.     int                location;        // location index for team mode
  273.     int                health;            // you only get this info about your teammates
  274.     int                armor;
  275.  
  276.     int                handicap;
  277.     int                wins;
  278.     int                losses;    
  279.  
  280.     int                mLastChatTime;
  281.  
  282.     int                teamTask;        // task in teamplay (offence/defence)
  283.     qboolean        teamLeader;        // true when this is a team leader
  284.  
  285.     int                gametypeitems;    // gametype items being carried
  286.  
  287.     // when clientinfo is changed, the loading of models/skins/sounds
  288.     // can be deferred until you are dead, to prevent hitches in
  289.     // gameplay
  290.     char            identityName[MAX_QPATH];
  291.     TIdentity*        identity;
  292.     qboolean        deferred;
  293.     qboolean        isMale;
  294.  
  295.     gender_t        gender;            // from model
  296.  
  297.     void            *ghoul2Model;
  298.     int                boltWorldWeapon;                        // bolt to use to hang world model of weapon on.
  299.     int                boltGametypeItems[MAX_GAMETYPE_ITEMS];    // bolt to use to hang gametype items to the player
  300.     int                boltNightvision;
  301.     
  302.     animation_t        animations[MAX_ANIMATIONS];
  303.     sfxHandle_t        sounds[MAX_CUSTOM_SOUNDS];
  304.  
  305.     qboolean        voice;
  306.  
  307. } clientInfo_t;
  308.  
  309. // Each weapon can have multiple attacsk.  SOF2 by default has 2 attacks 
  310. // per weapon, the standard attack and an alternate attack.
  311. typedef struct weaponAttack_s
  312. {
  313.     qhandle_t        ammoIcon;
  314.  
  315.     sfxHandle_t        flashSound[4];            // fast firing weapons randomly choose
  316.     sfxHandle_t        firingSound;
  317.     sfxHandle_t        missileSound;
  318.     float            missileDlight;
  319.     vec3_t            missileDlightColor;
  320.     sfxHandle_t        missileHitSound;
  321.     int                shellEjectBoltView;        // bolt for shell eject fx 
  322.     int                muzzleFlashBoltView;    // bolt for flash fx
  323.     int                shellEjectBoltWorld;    // bolt for shell eject fx 
  324.     int                muzzleFlashBoltWorld;    // bolt for flash fx
  325.     fxHandle_t        muzzleEffect;            // muzzle flash effect in view
  326.     fxHandle_t        muzzleEffectInWorld;
  327.     fxHandle_t        tracerEffect;            // used for either a bullet tracer OR for a projectile trail effect
  328.     fxHandle_t        shellEject;                // shell eject effect
  329.     sfxHandle_t        explosionSound;            // used for when a projectile explodes
  330.     fxHandle_t        explosionEffect;
  331.     void             *missileG2Model;        // ghoul2 model for missle
  332.  
  333.     void            (*missileTrailFunc)( centity_t *, int weaponNum );
  334.  
  335. } attackInfo_t;
  336.  
  337. // each WP_* weapon enum has an associated weaponInfo_t
  338. // that contains media references necessary to present the
  339. // weapon and its effects
  340. typedef struct weaponInfo_s 
  341. {
  342.     qboolean        registered;
  343.     gitem_t            *item;
  344.  
  345.     void            *weaponG2Model;        // ghoul2 model for 3rd person and in game world
  346.     void            *viewG2Model;        // ghoul2 model for 1st person view
  347.     int                viewG2Indexes[8];    // indexes for models in viewG2Model because ghoul2 is whacky!
  348.  
  349.     vec3_t            weaponMidpoint;        // so it will rotate centered instead of by tag
  350.  
  351.     qhandle_t        weaponIcon;
  352.  
  353.     void            *ammoG2Model;         // ghoul2 model for ammo
  354.  
  355.     attackInfo_t    attack[ATTACK_MAX];
  356.  
  357.     // All
  358.     sfxHandle_t        otherWeaponSounds[MAX_WEAPON_SOUNDS][MAX_WEAPON_SOUND_SLOTS];
  359.  
  360.     int                goreStyle;
  361.  
  362. } weaponInfo_t;
  363.  
  364.  
  365. // each IT_* item has an associated itemInfo_t
  366. // that constains media references necessary to present the
  367. // item and its effects
  368. typedef struct 
  369. {
  370.     qboolean        registered;
  371.     qhandle_t        models[MAX_ITEM_MODELS];
  372.     qhandle_t        icon, mSimpleIcon;
  373.  
  374.     void            *g2Models[MAX_ITEM_MODELS];
  375.     float            radius[MAX_ITEM_MODELS];
  376.  
  377.     void*            boltModel;
  378.     void*            useModel;
  379.  
  380. } itemInfo_t;
  381.  
  382.  
  383. //======================================================================
  384.  
  385. // all cg.stepTime, cg.duckTime, cg.landTime, etc are set to cg.time when the action
  386. // occurs, and they will have visible effects for #define STEP_TIME or whatever msec after
  387.  
  388. #define MAX_PREDICTED_EVENTS    16
  389.  
  390. typedef struct 
  391. {
  392.     int                clientFrame;            // incremented each frame
  393.                     
  394.     int                clientNum;
  395.                     
  396.     qboolean        demoPlayback;
  397.     qboolean        levelShot;                // taking a level menu screenshot
  398.     int                deferredPlayerLoading;
  399.     qboolean        loading;                // don't defer players at initial startup
  400.     qboolean        intermissionStarted;    // don't play voice rewards, because game will end shortly
  401.  
  402.     // there are only one or two snapshot_t that are relevent at a time
  403.     int                latestSnapshotNum;        // the number of snapshots the client system has received
  404.     int                latestSnapshotTime;        // the time from latestSnapshotNum, so we don't need to read the snapshot yet
  405.                                             
  406.     snapshot_t        *snap;                    // cg.snap->serverTime <= cg.time
  407.     snapshot_t        *nextSnap;                // cg.nextSnap->serverTime > cg.time, or NULL
  408.     qboolean        needNextSnap;
  409. //    snapshot_t        activeSnapshots[2];
  410.  
  411.     float            frameInterpolation;        // (float)( cg.time - cg.frame->serverTime ) / (cg.nextFrame->serverTime - cg.frame->serverTime)
  412.                     
  413.     qboolean        mMapChange;                // true if map is changing
  414.                     
  415.     qboolean        thisFrameTeleport;
  416.     qboolean        nextFrameTeleport;
  417.                     
  418.     int                frametime;                // cg.time - cg.oldTime
  419.                     
  420.     int                time;                    // this is the time value that the client
  421.                                             // is rendering at.
  422.     int                oldTime;                // time at last frame, used for missile trails and prediction checking
  423.                                             
  424.     int                physicsTime;            // either cg.snap->time or cg.nextSnap->time
  425.                                                         
  426.     qboolean        mapRestart;                // set on a map restart to set back the weapon
  427.     qboolean        gametypeStarted;        // has the gametype started yet?
  428.     qboolean        mInRMG;
  429.                     
  430.     qboolean        renderingThirdPerson;    // during deaths, chasecams, etc
  431.  
  432.     // prediction state
  433.     qboolean        hyperspace;                // true if prediction has hit a trigger_teleport
  434.     playerState_t    predictedPlayerState;
  435.     qboolean        validPPS;                // clear until the first call to CG_PredictPlayerState
  436.     int                predictedErrorTime;
  437.     vec3_t            predictedError;
  438.                     
  439.     int                eventSequence;
  440.     int                predictableEvents[MAX_PREDICTED_EVENTS];
  441.                     
  442.     float            stepChange;                // for stair up smoothing
  443.     int                stepTime;
  444.                     
  445.     float            duckChange;                // for duck viewheight smoothing
  446.     int                duckTime;
  447.                     
  448.     float            landChange;                // for landing hard
  449.     int                landTime;
  450.                     
  451.     int                deathTime;                // time of death
  452.  
  453.     // input state sent to server
  454.     int                weaponSelect;
  455.     int                weaponLastSelect;
  456.     int                weaponOldSelect;
  457.     int                weaponMenuSelect;
  458.                     
  459.     qboolean        weaponMenuUp;            // weapon menu shown
  460.  
  461.     // auto rotating items
  462.     vec3_t            autoAngles;
  463.     vec3_t            autoAxis[3];
  464.     vec3_t            autoAnglesFast;
  465.     vec3_t            autoAxisFast[3];
  466.  
  467.     // view rendering
  468.     refdef_t        refdef;
  469.                     
  470.     // zoom key        
  471.     int                zoomTime;
  472.     float            zoomSensitivity;
  473.  
  474.     // information screen text during loading
  475.     char            infoScreenText[MAX_STRING_CHARS];
  476.  
  477.     // scoreboard
  478.     int                scoresRequestTime;
  479.     int                numScores;
  480.     int                teamScores[2];
  481.     score_t            scores[MAX_CLIENTS];
  482.     qboolean        showScores;
  483.     qboolean        scoreBoardShowing;                            // Whether or not the scoreboard is showing
  484.     float            scoreBoardBottom;                            // Bottom coordinate of the scoreboard
  485.     char            scoreBoardSpectators[1024];                    // spectators string
  486.     int                scoreFadeTime;
  487.     qboolean        showAutomap;
  488.     char            killerName[MAX_NAME_LENGTH];
  489.     int                spectatorTime;                                // next time to offset
  490.  
  491.     // centerprinting
  492.     int                centerPrintTime;
  493.     char            centerPrint[1024];
  494.     int                centerPrintLines;
  495.     float            centerPrintScale;
  496.  
  497.     // kill timers for carnage reward
  498.     int                lastKillTime;
  499.  
  500.     // crosshair client ID
  501.     int                crosshairClientNum;
  502.     int                crosshairClientTime;
  503.     int                crosshairColorClientNum;
  504.  
  505.     vec4_t            crosshairRGBA;
  506.     vec4_t            crosshairFriendRGBA;
  507.  
  508.     // attacking player
  509.     int                attackerTime;
  510.     int                voiceTime;
  511.  
  512.     // sound buffer mainly for announcer sounds
  513.     int                soundBufferIn;
  514.     int                soundBufferOut;
  515.     int                soundTime;
  516.     qhandle_t        soundBuffer[MAX_SOUNDBUFFER];
  517.  
  518.     // for voice chat buffer
  519.     int                voiceChatTime;
  520.     int                voiceChatBufferIn;
  521.     int                voiceChatBufferOut;
  522.  
  523.     // warmup countdown
  524.     int                warmup;
  525.     int                warmupCount;
  526.  
  527.     //==========================
  528.  
  529.     int                itemPickup;
  530.  
  531.     int                weaponSelectTime;
  532.     int                weaponAnimation;
  533.     int                weaponAnimationTime;
  534.  
  535.     // blend blobs
  536.     float            damageTime;
  537.     float            damageX;
  538.     float            damageY;
  539.  
  540.     // view movement
  541.     float            v_dmg_pitch;
  542.     float            v_dmg_roll;
  543.  
  544.     // temp working variables for player view
  545.     float            bobfracsin;
  546.     int                bobcycle;
  547.     float            xyspeed;
  548.     int                nextOrbitTime;
  549.  
  550.     int                loadStage;
  551.  
  552.     // development tool
  553.     refEntity_t        testModelEntity;
  554.     char            testModelName[MAX_QPATH];
  555.     qboolean        testGun;
  556.     int                testModel;
  557.  
  558.     // had to be moved so we wouldn't wipe these out with the memset
  559.     snapshot_t        activeSnapshots[3];
  560.     int                activeSnapshot;
  561.  
  562.     TAnimInfoWeapon*    viewWeaponAnim[5];
  563.  
  564.     int                    weaponHideModels;
  565.  
  566.     CFxBoltInterface    flashBoltInterface;
  567.  
  568.     qboolean            cheats;
  569.  
  570.     qboolean            popupObjectives;
  571.  
  572.     float                shakeIntensity;
  573.     int                    shakeDuration;
  574.     int                    shakeStart;
  575.  
  576.     char                sharedBuffer[MAX_CG_SHARED_BUFFER_SIZE];
  577.     
  578.     centity_t*            radarEntities[MAX_GAMETYPE_ITEMS+MAX_CLIENTS];
  579.     int                    radarEntityCount;
  580.  
  581.     int                    flashbangTime;
  582.     int                    flashbangFadeTime;
  583.     float                flashbangAlpha;
  584.  
  585.     animation_t            hitAnimations[MAX_ANIMATIONS];
  586.     TGhoul2                hitModel;
  587.  
  588. } cg_t;
  589.  
  590. extern centity_t            cg_entities[MAX_GENTITIES];
  591. extern centity_t            *cg_permanents[MAX_GENTITIES];
  592. extern int                    cg_numpermanents;
  593.  
  594.  
  595. // all of the model, shader, and sound references that are
  596. // loaded at gamestate time are stored in cgMedia_t
  597. // Other media that can be tied to clients, weapons, or items are
  598. // stored in the clientInfo_t, itemInfo_t, weaponInfo_t
  599. typedef struct 
  600. {
  601.     qhandle_t    whiteShader;
  602.  
  603.     qhandle_t    armorShader;
  604.  
  605.     qhandle_t    blueFriendShader;
  606.     qhandle_t    redFriendShader;
  607.     qhandle_t    deadShader;
  608.  
  609.     qhandle_t    radarShader;
  610.  
  611.     qhandle_t    botSmallShader;
  612.  
  613.     qhandle_t    crosshairShader[NUM_CROSSHAIRS];
  614.     qhandle_t    lagometerShader;
  615.     qhandle_t    disconnectShader;
  616.     qhandle_t    backTileShader;
  617.  
  618.     qhandle_t    loadClipShader;
  619.     qhandle_t    loadBulletShader;
  620.  
  621.     qhandle_t    smokePuffShader;
  622.     qhandle_t    waterBubbleShader;
  623.  
  624.     qhandle_t    shadowMarkShader;
  625.  
  626.     // wall mark shaders
  627.     qhandle_t    wakeMarkShader;
  628.     qhandle_t    bloodMarkShader;
  629.     qhandle_t    burnMarkShader;
  630.  
  631.     // scoreboard headers
  632.     qhandle_t    scoreboard;
  633.     qhandle_t    scoreboardHeader;
  634.     qhandle_t    scoreboardLine;
  635.     qhandle_t    scoreboardFooter;
  636.     qhandle_t    scoreboardTotals;
  637.  
  638.     // sounds
  639.     sfxHandle_t talkSound;
  640.  
  641.     sfxHandle_t    waterLeave;
  642.     sfxHandle_t waterJumpIn;
  643.     sfxHandle_t    waterFootstep[2];
  644.     sfxHandle_t    waterWade[2];
  645.  
  646.     sfxHandle_t    armorHitSound[2];
  647.     sfxHandle_t fleshHitSound[2];
  648.  
  649.     qhandle_t    cursor;
  650.  
  651.     // Fonts
  652.     qhandle_t    lcdFont;
  653.     qhandle_t    hudFont;
  654.  
  655.     qhandle_t    glassBreakSound;
  656.     qhandle_t    respawnSound;
  657.     qhandle_t    itemRespawnSound;
  658.     qhandle_t    fragSound;
  659.     qhandle_t    fragSelfSound;
  660.  
  661.     qhandle_t    goSound;
  662.  
  663.     qhandle_t    zoomSound;
  664.     qhandle_t    gogglesOnSound;
  665.     qhandle_t    gogglesOffSound;
  666.  
  667.     qhandle_t    flybySounds[NUMFLYBYS];
  668.  
  669.     qhandle_t    drownPainSound[2];
  670.     qhandle_t    drownDeathSound;
  671.  
  672.     qhandle_t    damageDirShader;
  673.     qhandle_t    playerFleshImpactEffect;
  674.     qhandle_t    glassChunkEffect;
  675.  
  676.     qhandle_t    mAutomap;
  677.     qhandle_t    mAutomapPlayerIcon;
  678.  
  679.     TGhoul2        nightVisionModel;
  680.  
  681.     qhandle_t    mBloodSmall;
  682.  
  683.     qhandle_t    test;
  684.  
  685. } cgMedia_t;
  686.  
  687.  
  688. // The client game static (cgs) structure hold everything
  689. // loaded or calculated from the gamestate.  It will NOT
  690. // be cleared when a map_restart is done
  691. typedef struct 
  692. {
  693.     gameState_t        gameState;            // gamestate from server
  694.     glconfig_t        glconfig;            // rendering configuration
  695.     float            screenXScale;        // derived from glconfig
  696.     float            screenYScale;
  697.     float            screenXBias;
  698.  
  699.     int                gameID;
  700.  
  701.     int                serverCommandSequence;    // reliable command stream counter
  702.     int                processedSnapshotNum;// the number of snapshots cgame has requested
  703.  
  704.     qboolean        localServer;        // detected on startup by checking sv_running
  705.  
  706.     // parsed from serverinfo
  707.     int                gametype;
  708.     gametypeData_t*    gametypeData;
  709.     int                dmflags;
  710.     int                teamflags;
  711.     int                scorelimit;
  712.     int                timelimit;
  713.     int                maxclients;
  714.     qboolean        friendlyFire;
  715.     char            mapname[MAX_QPATH];
  716.     char            gameover[MAX_QPATH];
  717.  
  718.     qboolean        pickupsDisabled;
  719.  
  720.     int                voteTime;
  721.     int                voteDuration;
  722.     int                voteYes;
  723.     int                voteNeeded;
  724.     int                voteNo;
  725.     qboolean        voteModified;            // beep whenever changed
  726.     char            voteString[MAX_STRING_TOKENS];
  727.  
  728.     int                levelStartTime;
  729.     int                gametypeTimerTime;
  730.     int                gametypeMessageTime;
  731.     char            gametypeMessage[MAX_STRING_TOKENS];
  732.  
  733.     int                scores1;
  734.     int                scores2;
  735.  
  736.     // locally derived information from gamestate
  737.     qhandle_t        gameModels[MAX_MODELS];
  738.     sfxHandle_t        gameSounds[MAX_SOUNDS];
  739.     qhandle_t        gameIcons[MAX_ICONS];
  740.     qhandle_t        skins[MAX_CHARSKINS];
  741.  
  742.     int                numInlineModels;
  743.     qhandle_t        inlineDrawModel[MAX_MODELS];
  744.     vec3_t            inlineModelMidpoints[MAX_MODELS];
  745.  
  746.     clientInfo_t    clientinfo[MAX_CLIENTS];
  747.  
  748.     // teamchat width is *3 because of embedded color codes
  749.     char            chatText[CHAT_HEIGHT][CHAT_WIDTH*3+1];
  750.     int                chatTime[CHAT_HEIGHT];
  751.     int                chatPos;
  752.     int                chatLastPos;
  753.  
  754.     int                cursorX;
  755.     int                cursorY;
  756.     qboolean        eventHandling;
  757.     void*            capturedItem;
  758.     qhandle_t        activeCursor;
  759.  
  760.     // media
  761.     cgMedia_t        media;
  762.  
  763.     vec3_t            mWorldMins;
  764.     vec3_t            mWorldMaxs;
  765.     float            mIRDist;
  766.     float            mIRSeeThrough;
  767.  
  768.     int                hudIcons[MAX_HUDICONS];
  769.  
  770. } cgs_t;
  771.  
  772. //==============================================================================
  773.  
  774. extern    cgs_t            cgs;
  775. extern    cg_t            cg;
  776. extern    weaponInfo_t    cg_weapons[MAX_WEAPONS];
  777. extern    itemInfo_t        cg_items[MAX_ITEMS];
  778.  
  779. extern    vmCvar_t        con_notifyTime;
  780. extern    vmCvar_t        cg_centertime;
  781. extern    vmCvar_t        cg_centerY;
  782. extern    vmCvar_t        cg_runpitch;
  783. extern    vmCvar_t        cg_runroll;
  784. extern    vmCvar_t        cg_bobup;
  785. extern    vmCvar_t        cg_bobpitch;
  786. extern    vmCvar_t        cg_bobroll;
  787. extern    vmCvar_t        cg_shadows;
  788. extern    vmCvar_t        cg_drawTimer;
  789. extern    vmCvar_t        cg_drawFPS;
  790. extern    vmCvar_t        cg_drawSnapshot;
  791. extern    vmCvar_t        cg_drawCrosshair;
  792. extern    vmCvar_t        cg_drawCrosshairNames;
  793. extern  vmCvar_t        cg_drawRadar;
  794. extern    vmCvar_t        cg_drawTeamScores;
  795. extern    vmCvar_t        cg_drawHUDIcons;
  796. extern    vmCvar_t        cg_crosshairX;
  797. extern    vmCvar_t        cg_crosshairY;
  798. extern    vmCvar_t        cg_crosshairSize;
  799. extern    vmCvar_t        cg_crosshairGrow;
  800. extern    vmCvar_t        cg_crosshairRGBA;
  801. extern    vmCvar_t        cg_crosshairFriendRGBA;
  802. extern    vmCvar_t        cg_draw2D;
  803. extern    vmCvar_t        cg_debugEvents;
  804. extern    vmCvar_t        cg_errorDecay;
  805. extern    vmCvar_t        cg_nopredict;
  806. extern    vmCvar_t        cg_showmiss;
  807. extern    vmCvar_t        cg_footsteps;
  808. extern    vmCvar_t        cg_gun_x;
  809. extern    vmCvar_t        cg_gun_y;
  810. extern    vmCvar_t        cg_gun_z;
  811. extern    vmCvar_t        cg_drawGun;
  812. extern    vmCvar_t        cg_autoswitch;
  813. extern    vmCvar_t        cg_ignore;
  814. extern    vmCvar_t        cg_simpleItems;
  815. extern    vmCvar_t        cg_fov;
  816. extern    vmCvar_t        cg_shellEjection;
  817.  
  818. extern    vmCvar_t        cg_goreDetail;
  819.  
  820. extern    vmCvar_t        cg_thirdPerson;
  821. extern    vmCvar_t        cg_thirdPersonRange;
  822. extern    vmCvar_t        cg_thirdPersonYaw;
  823. extern    vmCvar_t        cg_thirdPersonPitch;
  824.  
  825. extern    vmCvar_t        cg_thirdPersonHorzOffset;
  826.  
  827. extern    vmCvar_t        cg_stereoSeparation;
  828. extern    vmCvar_t        cg_lagometer;
  829. extern    vmCvar_t        cg_synchronousClients;
  830. extern    vmCvar_t        cg_chatTime;
  831. extern    vmCvar_t        cg_chatHeight;
  832. extern    vmCvar_t        cg_stats;
  833. extern    vmCvar_t         cg_forceModel;
  834. extern    vmCvar_t         cg_buildScript;
  835. extern    vmCvar_t        cg_paused;
  836. extern    vmCvar_t        cg_predictItems;
  837. extern    vmCvar_t        cg_antiLag;
  838. extern    vmCvar_t        cg_impactPrediction;
  839. extern    vmCvar_t        cg_autoReload;
  840. extern    vmCvar_t        cg_deferPlayers;
  841. extern    vmCvar_t        cg_drawFriend;
  842. extern    vmCvar_t        cg_teamChatsOnly;
  843. extern    vmCvar_t        cg_noVoiceText;
  844. extern    vmCvar_t        cg_smoothClients;
  845. extern    vmCvar_t        pmove_fixed;
  846. extern    vmCvar_t        pmove_msec;
  847. extern    vmCvar_t        cg_cameraOrbit;
  848. extern    vmCvar_t        cg_cameraOrbitDelay;
  849. extern    vmCvar_t        cg_timescale;
  850. extern    vmCvar_t        cg_cameraMode;
  851. extern    vmCvar_t        cg_noTaunt;
  852. extern    vmCvar_t        cg_noProjectileTrail;
  853. extern    vmCvar_t        cg_currentSelectedPlayer;
  854. extern    vmCvar_t        cg_currentSelectedPlayerName;
  855.  
  856. extern    vmCvar_t        cg_DebugGore;
  857.  
  858. extern    vmCvar_t        cg_lockSever;
  859. extern    vmCvar_t        cg_lockBlood;
  860. extern    vmCvar_t        cg_lockDeaths;
  861.  
  862. extern    vmCvar_t        RMG_distancecull;
  863. extern    vmCvar_t        cg_damageindicator;
  864. extern    vmCvar_t        cg_tracerChance;
  865.  
  866. extern    vmCvar_t        cg_animBlend;
  867.  
  868. extern    vmCvar_t        cg_automap_x;
  869. extern    vmCvar_t        cg_automap_y;
  870. extern    vmCvar_t        cg_automap_w;
  871. extern    vmCvar_t        cg_automap_h;
  872. extern    vmCvar_t        cg_automap_a;
  873.  
  874. extern    vmCvar_t        ui_info_redcount;
  875. extern    vmCvar_t        ui_info_bluecount;
  876. extern    vmCvar_t        ui_info_speccount;
  877. extern    vmCvar_t        ui_info_freecount;
  878. extern  vmCvar_t        ui_info_pickupsdisabled;
  879. extern    vmCvar_t        ui_info_seenobjectives;
  880.  
  881. extern    vmCvar_t        cg_voiceRadio;
  882. extern    vmCvar_t        cg_voiceGlobal;
  883. extern    vmCvar_t        cg_soundGlobal;
  884. extern    vmCvar_t        cg_soundFrag;
  885. extern    vmCvar_t        cg_weaponMenuFast;
  886.  
  887. extern    vmCvar_t        cg_bodyTime;
  888.  
  889. extern    vmCvar_t        rw_enabled;
  890.  
  891. extern    vmCvar_t        cg_zoomWeaponChange;
  892.  
  893. //
  894. // cg_main.c
  895. //
  896. const char *CG_ConfigString                    ( int index );
  897. const char *CG_Argv                            ( int arg );
  898. centity_t*    CG_GetEntity                    ( int index );
  899. void        CG_StartMusic                    ( qboolean bForceStart );
  900. void        CG_UpdateCvars                    ( void );
  901. void        CG_UpdateTeamCountCvars            ( void );
  902. int            CG_CrosshairPlayer                ( void );
  903. int            CG_LastAttacker                    ( void );
  904. void        CG_LoadMenus                    ( const char *menuFile);
  905. void        CG_KeyEvent                        ( int key, qboolean down);
  906. void        CG_MouseEvent                    ( int x, int y);
  907. void        CG_EventHandling                ( int type);
  908.                                             
  909. //                                            
  910. // cg_view.c                                
  911. //                                            
  912. void        CG_TestModel_f                    (void);
  913. void        CG_TestGun_f                    (void);
  914. void        CG_TestModelNextFrame_f            (void);
  915. void        CG_TestModelPrevFrame_f            (void);
  916. void        CG_TestModelNextSkin_f            (void);
  917. void        CG_TestModelPrevSkin_f            (void);
  918. void        CG_AddBufferedSound                ( sfxHandle_t sfx);
  919. void        CG_DrawActiveFrame                ( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback );
  920. void        CG_CameraShake                    ( float* origin, float intensity, int radius, int time );
  921. void        CG_UpdateCameraShake            ( vec3_t origin, vec3_t angles );        
  922.                                             
  923. //                                            
  924. // cg_drawtools.c                            
  925. //                                            
  926. void        CG_AdjustFrom640                ( float *x, float *y, float *w, float *h );
  927. void        CG_FillRect                        ( float x, float y, float width, float height, const float *color );
  928. void        CG_DrawPic                        ( float x, float y, float width, float height, qhandle_t hShader );
  929. void        CG_DrawStretchPic                ( float x, float y, float width, float height, float sx, float sy, float sw, float sh, const float* color, qhandle_t hShader );
  930. void        CG_DrawRotatePic                ( float x, float y, float width, float height,float angle, qhandle_t hShader );
  931. void        CG_DrawRotatePic2                ( float x, float y, float width, float height,float angle, qhandle_t hShader );
  932. int            CG_DrawStrlen                    ( const char *str );
  933. float*        CG_FadeColor                    ( int startMsec, int totalMsec );
  934. float*        CG_TeamColor                    ( int team );
  935. void        CG_TileClear                    ( void );
  936. void        CG_DrawRect                        ( float x, float y, float width, float height, float size, const float *color );
  937. void        CG_DrawSides                    ( float x, float y, float w, float h, float size);
  938. void        CG_DrawTopBottom                ( float x, float y, float w, float h, float size);
  939. void        CG_GetColorForHealth            ( vec4_t color, int health, int armor );
  940. void        CG_DrawText                        ( float x, float y, qhandle_t font, float scale, vec4_t color, const char* text, int limit, int flags );
  941. void        CG_DrawTextWithCursor            ( float x, float y, qhandle_t font, float scale, vec4_t color, const char* text, int limit, int flags, int cursorPos, char cursor );
  942. void        CG_DrawTimer                    ( float x, float y, qhandle_t font, float scale, vec4_t color, int flags, int msec );
  943.  
  944. //
  945. // cg_draw.c, cg_newDraw.c
  946. //
  947. void        CG_AddLagometerFrameInfo        ( void );
  948. void        CG_AddLagometerSnapshotInfo        ( snapshot_t *snap );
  949. void        CG_CenterPrint                    ( const char *str, float scale );
  950. void        CG_DrawActive                    ( stereoFrame_t stereoView );
  951. void        CG_OwnerDraw                    ( float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, qhandle_t font, float scale, vec4_t color, qhandle_t shader, int textStyle, const char* param );
  952. float        CG_GetValue                        ( int ownerDraw );
  953. qboolean    CG_OwnerDrawVisible                ( int flags, const char* param );
  954. qboolean    CG_OwnerDrawDisabled            ( int flags, const char* param );
  955. void        CG_RunMenuScript                ( const char **args);
  956. void        CG_GetTeamColor                    ( vec4_t *color);
  957. const char*    CG_GetGameStatusText            ( void );
  958. void        CG_Draw3DModel                    ( float x, float y, float w, float h, qhandle_t model, qhandle_t skin, vec3_t origin, vec3_t angles );
  959. void        CG_Draw3DG2Model                ( float x, float y, float w, float h, void *ghoul2, qhandle_t skin, vec3_t origin, vec3_t angles ); 
  960. void        CG_Text_PaintChar                ( float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, qhandle_t hShader );
  961. const char*    CG_GameTypeString                ( void );
  962. void        CG_DrawMapChange                ( void );
  963.  
  964. //
  965. // cg_player.c
  966. //
  967. void        CG_Player                        ( centity_t *cent );
  968. void        CG_ResetPlayerEntity            ( centity_t *cent );
  969. void        CG_NewClientInfo                ( int clientNum );
  970. sfxHandle_t    CG_CustomSound                    ( int clientNum, const char *soundName);
  971. sfxHandle_t    CG_CustomPlayerSound            ( int clientNum, ECustomSounds sound); 
  972. void        CG_UpdatePlayerModel            ( centity_t* cent);
  973. TGhoul2        CG_RegisterIdentity                ( TIdentity* identity, char *animationFile, gender_t* gender );
  974. void        CG_RemoveIdentityItemsOnBack    ( centity_t* cent );
  975. qboolean    CG_PlayerShadow                    ( centity_t *cent, float *shadowPlane );
  976.  
  977. //
  978. // cg_predict.c
  979. //
  980. void        CG_BuildSolidList                ( void );
  981. int            CG_PointContents                ( const vec3_t point, int passEntityNum );
  982. void        CG_Trace                        ( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int skipNumber, int mask );
  983. void        CG_PlayerTrace                    ( trace_t* tr, const vec3_t start, const vec3_t end, int skipNumber );
  984. void        CG_PredictPlayerState            ( void );
  985. void        CG_LoadDeferredPlayers            ( void );
  986. void        CG_InitHitModel                    ( void );
  987.  
  988. //
  989. // cg_events.c
  990. //
  991. void        CG_CheckEvents                    ( centity_t *cent );
  992. const char*    CG_PlaceString                    ( int rank );
  993. void        CG_EntityEvent                    ( centity_t *cent, vec3_t position );
  994. void        CG_PainEvent                    ( centity_t *cent, int health );
  995.  
  996. //
  997. // cg_ents.c
  998. //
  999. float*        CG_SetEntitySoundPosition        ( centity_t *cent );
  1000. void        CG_AddPacketEntities            ( void );
  1001. void        CG_Beam                            ( centity_t *cent );
  1002. void        CG_AdjustPositionForMover        ( const vec3_t in, int moverNum, int fromTime, int toTime, vec3_t out );
  1003. void        CG_ScaleModelAxis                ( refEntity_t* ent );
  1004.  
  1005. //
  1006. // cg_weapons.c
  1007. //
  1008. void        CG_NextWeapon                    ( qboolean allowEmpty, int exclude );
  1009. void        CG_PrevWeapon                    ( qboolean allowEmpty, int exclude );
  1010. void        CG_Weapon_f                        ( void );
  1011. qboolean    CG_WeaponSelectable                ( int i, qboolean allowEmpty );
  1012. void        CG_RegisterWeapon                ( int weaponNum);
  1013. void        CG_ShutDownWeapons                ( void);
  1014. void        CG_RegisterItemVisuals            ( int itemNum );
  1015. void        CG_UpdateViewWeaponSurfaces        ( playerState_t* ps );
  1016. void        CG_SetWeaponAnim                ( int weaponAnim, playerState_t *ps );
  1017. void        CG_FireWeapon                    ( centity_t *cent, attackType_t attack );
  1018. void        CG_ProjectileThink                ( centity_t *cent, int weaponNum );
  1019. void        CG_MissileHitWall                ( int weapon, vec3_t origin, vec3_t dir, int material, attackType_t attack );
  1020. void        CG_MissileHitPlayer                ( int weapon, vec3_t origin, vec3_t dir, int entityNum, attackType_t attack );
  1021. void        CG_HandleStickyMissile            ( centity_t *cent,entityState_t *es,vec3_t dir,int targetEnt);
  1022. void        CG_Bullet                        ( vec3_t end, int sourceEntityNum, int weapon, vec3_t normal, int fleshEntityNum, int material, attackType_t attack );
  1023. void        CG_AnimateViewWeapon            ( playerState_t *ps );
  1024. void        CG_AddViewWeapon                ( playerState_t *ps );
  1025. void        CG_PlayerWeaponEffects            ( refEntity_t *parent, centity_t *cent, int team, vec3_t newAngles );
  1026. void        CG_DrawWeaponSelect                ( void );
  1027. void        CG_OutOfAmmoChange                ( int lastWeapon );    
  1028. void        CG_WeaponCallback                ( playerState_t* ps, centity_t* cent, int weapon, int anim, int animChoice, int step );
  1029.  
  1030. //
  1031. // cg_localents.c
  1032. //
  1033. void            CG_InitLocalEntities        ( void );
  1034. void            CG_FreeLocalEntity            ( localEntity_t *le );
  1035. localEntity_t*    CG_AllocLocalEntity            ( void );
  1036. void            CG_AddLocalEntities            ( void );
  1037.  
  1038. //
  1039. // cg_effects.c
  1040. //
  1041. void        CG_BubbleTrail                    ( vec3_t start, vec3_t end, float spacing );
  1042. void        CG_BulletFlyBySound                ( vec3_t start, vec3_t end );
  1043. void        CG_GlassShatter                    ( int entnum, vec3_t org, vec3_t mins, vec3_t maxs);
  1044. void        CG_TestLine                        ( vec3_t start, vec3_t end, int time, unsigned int color, int radius);
  1045.  
  1046. //
  1047. // cg_snapshot.c
  1048. //
  1049. void        CG_ProcessSnapshots                ( void );
  1050.  
  1051. //
  1052. // cg_info.c
  1053. //
  1054. void        CG_LoadingString                ( const char *s );
  1055. void        CG_LoadingStage                    ( int stage );
  1056. void        CG_LoadingItem                    ( int itemNum );
  1057. void        CG_LoadingClient                ( int clientNum );
  1058. void        CG_DrawInformation                ( void );
  1059.                                                     
  1060. //                                                    
  1061. // cg_scoreboard.c                                    
  1062. //                                                
  1063. qboolean    CG_DrawScoreboard                ( void );
  1064.                                                     
  1065. //                                                    
  1066. // cg_consolecmds.c                                    
  1067. //                                                    
  1068. qboolean    CG_ConsoleCommand                ( void );
  1069. void        CG_InitConsoleCommands            ( void );
  1070.                                                     
  1071. //                                                    
  1072. // cg_servercmds.c                                    
  1073. //                                                    
  1074. void        CG_MapRestart                    ( qboolean gametypeRestart );
  1075. void        CG_ExecuteNewServerCommands        ( int latestSequence );
  1076. void        CG_ParseServerinfo                ( void );
  1077. void        CG_SetConfigValues                ( void );
  1078. void        CG_LoadVoiceChats                ( void );
  1079. void        CG_ShaderStateChanged            ( void );
  1080. void        CG_VoiceChatLocal                ( qboolean voiceOnly, int clientNum, const char* chatprefix, const char *cmd );
  1081. void        CG_PlayBufferedVoiceChats        ( void );
  1082.  
  1083. //
  1084. // cg_playerstate.c
  1085. //
  1086. void        CG_Respawn                            ( void );
  1087. void        CG_TransitionPlayerState            ( playerState_t *ps, playerState_t *ops );
  1088. void        CG_CheckChangedPredictableEvents    ( playerState_t *ps );
  1089.  
  1090. //
  1091. // cg_playeranim.c
  1092. //
  1093. qboolean    CG_ParseAnimationFile    ( const char *filename, clientInfo_t *ci) ;
  1094.  
  1095. //
  1096. // cg_gore.c
  1097. //
  1098. qboolean    CG_ParseGore    ( void );
  1099. void        CG_ApplyGore    ( int clientNum, centity_t *cent, int hitLocation, vec3_t Direction);
  1100.  
  1101.  
  1102. //===============================================
  1103.  
  1104. //
  1105. // system traps
  1106. // These functions are how the cgame communicates with the main game system
  1107. //
  1108. // print message on the local console
  1109. void        trap_Print                        ( const char *fmt );
  1110.  
  1111. // abort the game
  1112. void        trap_Error                        ( const char *fmt );
  1113.  
  1114. // milliseconds should only be used for performance tuning, never
  1115. // for anything game related.  Get time from the CG_DrawActiveFrame parameter
  1116. int            trap_Milliseconds                ( void );
  1117.  
  1118. // console variable interaction
  1119. void        trap_Cvar_Register                ( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags, float MinValue, float MaxValue );
  1120. void        trap_Cvar_Update                ( vmCvar_t *vmCvar );
  1121. void        trap_Cvar_Set                    ( const char *var_name, const char *value );
  1122. void        trap_Cvar_VariableStringBuffer    ( const char *var_name, char *buffer, int bufsize );
  1123.  
  1124. // ServerCommand and ConsoleCommand parameter access
  1125. int            trap_Argc                        ( void );
  1126. void        trap_Argv                        ( int n, char *buffer, int bufferLength );
  1127. void        trap_Args                        ( char *buffer, int bufferLength );
  1128.  
  1129. // filesystem access
  1130. // returns length of file
  1131. int            trap_FS_FOpenFile                ( const char *qpath, fileHandle_t *f, fsMode_t mode );
  1132. void        trap_FS_Read                    ( void *buffer, int len, fileHandle_t f );
  1133. void        trap_FS_Write                    ( const void *buffer, int len, fileHandle_t f );
  1134. void        trap_FS_FCloseFile                ( fileHandle_t f );
  1135. int            trap_FS_GetFileList                ( const char *path, const char *extension, char *listbuf, int bufsize );
  1136.  
  1137. // add commands to the local console as if they were typed in
  1138. // for map changing, etc.  The command is not executed immediately,
  1139. // but will be executed in order the next time console commands
  1140. // are processed
  1141. void        trap_SendConsoleCommand            ( const char *text );
  1142.  
  1143. // register a command name so the console can perform command completion.
  1144. // FIXME: replace this with a normal console command "defineCommand"?
  1145. void        trap_AddCommand                    ( const char *cmdName );
  1146.  
  1147. // send a string to the server over the network
  1148. void        trap_SendClientCommand            ( const char *s );
  1149.  
  1150. // force a screen update, only used during gamestate load
  1151. void        trap_UpdateScreen                ( void );
  1152.  
  1153. // model collision
  1154. void         trap_CM_LoadMap                    ( const char *mapname, qboolean SubBSP );
  1155. int             trap_CM_NumInlineModels            ( void );
  1156. clipHandle_t trap_CM_InlineModel                ( int index );        // 0 = world, 1+ = bmodels
  1157. clipHandle_t trap_CM_TempBoxModel                ( const vec3_t mins, const vec3_t maxs );
  1158. int             trap_CM_PointContents                ( const vec3_t p, clipHandle_t model );
  1159. int             trap_CM_TransformedPointContents    ( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles );
  1160. void         trap_CM_BoxTrace                    ( trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask );
  1161. void         trap_CM_TransformedBoxTrace        ( trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask, const vec3_t origin, const vec3_t angles );
  1162.  
  1163. // Returns the projection of a polygon onto the solid brushes in the world
  1164. int            trap_CM_MarkFragments                ( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer );
  1165.  
  1166. // normal sounds will have their volume dynamically changed as their entity
  1167. // moves and the listener moves
  1168. void        trap_S_StopAllSounds        ( void );
  1169. void        trap_S_StartSound            ( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx, int volume, int radius );
  1170. void        trap_S_StopLoopingSound        ( int entnum );
  1171.  
  1172. // a local sound is always played full volume
  1173. void        trap_S_StartLocalSound        ( sfxHandle_t sfx, int channelNum );
  1174. void        trap_S_ClearLoopingSounds    ( qboolean killall );
  1175. void        trap_S_AddLoopingSound        ( int entityNum, const vec3_t origin, const vec3_t velocity, float radius, sfxHandle_t sfx );
  1176. void        trap_S_AddRealLoopingSound    ( int entityNum, const vec3_t origin, const vec3_t velocity, float radius, sfxHandle_t sfx );
  1177. void        trap_S_UpdateEntityPosition    ( int entityNum, const vec3_t origin );
  1178.  
  1179. // repatialize recalculates the volumes of sound as they should be heard by the
  1180. // given entityNum and position
  1181. void        trap_S_Respatialize            ( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater );
  1182. sfxHandle_t    trap_S_RegisterSound        ( const char *sample);        // returns buzz if not found
  1183. void        trap_S_StartBackgroundTrack    ( const char *intro, const char *loop, qboolean bReturnWithoutStarting);    // empty name stops music
  1184. void        trap_S_StopBackgroundTrack    ( void );
  1185.  
  1186. void        trap_AS_AddPrecacheEntry    ( const char *set);
  1187. void        trap_AS_ParseSets            ( void );
  1188. void        trap_AS_UpdateAmbientSet    ( const char *name, vec3_t origin);
  1189. int            trap_AS_AddLocalSet            ( const char *name, vec3_t listener_origin, vec3_t origin, int entID, int time);
  1190. sfxHandle_t    trap_AS_GetBModelSound        ( const char *name, int stage);
  1191.  
  1192.  
  1193. void        trap_R_LoadWorldMap            ( const char *mapname );
  1194.  
  1195. // all media should be registered during level startup to prevent
  1196. // hitches during gameplay
  1197. qhandle_t    trap_R_RegisterModel        ( const char *name );            // returns rgb axis if not found
  1198. qhandle_t    trap_R_RegisterSkin            ( const char *name );            // returns all white if not found
  1199. qhandle_t    trap_R_RegisterShader        ( const char *name );            // returns all white if not found
  1200. qhandle_t    trap_R_RegisterShaderNoMip    ( const char *name );            // returns all white if not found
  1201. qhandle_t    trap_R_RegisterFont            ( const char *fontName );
  1202.  
  1203. // a scene is built up by calls to R_ClearScene and the various R_Add functions.
  1204. // Nothing is drawn until R_RenderScene is called.
  1205. void        trap_R_ClearScene            ( void );
  1206. void        trap_R_ClearDecals            ( void );
  1207. void        trap_R_AddRefEntityToScene    ( const refEntity_t *re );
  1208.  
  1209. int            trap_R_GetTextWidth            ( const char* text, qhandle_t font, float scale, int limit );
  1210. int            trap_R_GetTextHeight        ( const char* text, qhandle_t font, float scale, int limit );
  1211. void        trap_R_DrawText                ( int x, int y, qhandle_t font, float scale, vec4_t color, const char* text, int limit, int flags );
  1212. void        trap_R_DrawTextWithCursor    ( int x, int y, qhandle_t font, float scale, vec4_t color, const char* text, int limit, int flags, int cursorPos, char cursor );
  1213.  
  1214. // polys are intended for simple wall marks, not really for doing
  1215. // significant construction
  1216. void        trap_R_AddPolyToScene        ( qhandle_t hShader , int numVerts, const polyVert_t *verts );
  1217. void        trap_R_AddPolysToScene        ( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys );
  1218. void        trap_R_AddDecalToScene        ( qhandle_t shader, const vec3_t origin, const vec3_t dir, float orientation, float r, float g, float b, float a, qboolean alphaFade, float radius, qboolean temporary );
  1219. void        trap_R_AddLightToScene        ( const vec3_t org, float intensity, float r, float g, float b );
  1220. int            trap_R_LightForPoint        ( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
  1221. void        trap_R_RenderScene            ( const refdef_t *fd );
  1222. void        trap_R_DrawVisualOverlay    ( visual_t type, qboolean preProcess, float parm1, float parm2 );
  1223. void        trap_R_SetColor                ( const float *rgba );    // NULL = 1,1,1,1
  1224. void        trap_R_DrawStretchPic        ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, const float* color, qhandle_t hShader );
  1225. void        trap_R_ModelBounds            ( clipHandle_t model, vec3_t mins, vec3_t maxs );
  1226. int            trap_R_LerpTag                ( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName );
  1227.  
  1228. // Does weird, barely controllable rotation behaviour
  1229. void        trap_R_DrawRotatePic        ( float x, float y, float w, float h, float s1, float t1, float s2, float t2,float a, qhandle_t hShader );
  1230.  
  1231. // rotates image around exact center point of passed in coords
  1232. void        trap_R_DrawRotatePic2        ( float x, float y, float w, float h, float s1, float t1, float s2, float t2,float a, qhandle_t hShader );
  1233. void        trap_R_RemapShader            ( const char *oldShader, const char *newShader, const char *timeOffset );
  1234.  
  1235. void        trap_R_GetLightStyle        ( int style, color4ub_t color);
  1236. void        trap_R_SetLightStyle        ( int style, int color);
  1237.  
  1238. // The glconfig_t will not change during the life of a cgame.
  1239. // If it needs to change, the entire cgame will be restarted, because
  1240. // all the qhandle_t are then invalid.
  1241. void        trap_GetGlconfig( glconfig_t *glconfig );
  1242.  
  1243. // the gamestate should be grabbed at startup, and whenever a
  1244. // configstring changes
  1245. void        trap_GetGameState( gameState_t *gamestate );
  1246.  
  1247. // cgame will poll each frame to see if a newer snapshot has arrived
  1248. // that it is interested in.  The time is returned seperately so that
  1249. // snapshot latency can be calculated.
  1250. void        trap_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime );
  1251.  
  1252. // a snapshot get can fail if the snapshot (or the entties it holds) is so
  1253. // old that it has fallen out of the client system queue
  1254. qboolean    trap_GetSnapshot( int snapshotNumber, snapshot_t *snapshot );
  1255.  
  1256.  
  1257. qboolean    trap_GetDefaultState(int entityIndex, entityState_t *state );
  1258.  
  1259. // retrieve a text command from the server stream
  1260. // the current snapshot will hold the number of the most recent command
  1261. // qfalse can be returned if the client system handled the command
  1262. // argc() / argv() can be used to examine the parameters of the command
  1263. qboolean    trap_GetServerCommand( int serverCommandNumber );
  1264.  
  1265. // returns the most recent command number that can be passed to GetUserCmd
  1266. // this will always be at least one higher than the number in the current
  1267. // snapshot, and it may be quite a few higher if it is a fast computer on
  1268. // a lagged connection
  1269. int            trap_GetCurrentCmdNumber( void );    
  1270.  
  1271. qboolean    trap_GetUserCmd( int cmdNumber, usercmd_t *ucmd );
  1272.  
  1273. // used for the weapon select and zoom
  1274. void        trap_SetUserCmdValue( int stateValue, float sensitivityScale );
  1275.  
  1276. void        trap_RW_SetTeam(int team, qboolean dead);
  1277.  
  1278. void        trap_ResetAutorun ( void );
  1279.  
  1280. // aids for VM testing
  1281. void        testPrintInt( char *string, int i );
  1282. void        testPrintFloat( char *string, float f );
  1283.  
  1284. // Cinematic playing
  1285. int            trap_CIN_PlayCinematic    ( const char *arg0, int xpos, int ypos, int width, int height, int bits);
  1286. e_status    trap_CIN_StopCinematic    ( int handle);
  1287. e_status    trap_CIN_RunCinematic    ( int handle);
  1288. void        trap_CIN_DrawCinematic    ( int handle);
  1289. void        trap_CIN_SetExtents        ( int handle, int x, int y, int w, int h);
  1290.  
  1291. // Special FX system traps
  1292. int            trap_FX_InitSystem            ( refdef_t* );
  1293. int            trap_FX_RegisterEffect        ( const char *file);
  1294. void        trap_FX_PlaySimpleEffect    ( const char *file, vec3_t org, int vol, int rad );                    // uses a default up axis
  1295. void        trap_FX_PlayEffect            ( const char *file, vec3_t org, vec3_t fwd, int vol, int rad );        // builds arbitrary perp. right vector, does a cross product to define up
  1296. void        trap_FX_PlayEntityEffect    ( const char *file, vec3_t org, vec3_t axis[3], const int boltInfo, const int entNum, int vol, int rad );
  1297. void        trap_FX_PlaySimpleEffectID    ( int id, vec3_t org, int vol, int rad );                    // uses a default up axis
  1298. void        trap_FX_PlayEffectID        ( int id, vec3_t org, vec3_t fwd, int vol, int rad );        // builds arbitrary perp. right vector, does a cross product to define up
  1299. void        trap_FX_PlayEntityEffectID    ( int id, vec3_t org, vec3_t axis[3], const int boltInfo, const int entNum, int vol, int rad );
  1300. void        trap_FX_PlayBoltedEffectID    (int id, CFxBoltInterface *obj, int vol, int rad );
  1301. void        trap_FX_AddScheduledEffects    ( void );
  1302. void        trap_FX_Draw2DEffects        ( float screenXScale, float screenYScale );
  1303. qboolean    trap_FX_FreeSystem            ( void );
  1304. void        trap_FX_AdjustTime            ( int time );
  1305. void        trap_FX_Reset                ( void );
  1306. void        trap_FX_AddLine                ( const vec3_t start, const vec3_t end, float size1, float size2, float sizeParm,
  1307.                                           float alpha1, float alpha2, float alphaParm,
  1308.                                           const vec3_t sRGB, const vec3_t eRGB, float rgbParm,
  1309.                                           int killTime, qhandle_t shader, int flags);
  1310.  
  1311. int            trap_MemoryRemaining        ( void );
  1312.  
  1313. // Keycatcher traps
  1314. qboolean    trap_Key_IsDown                ( int keynum );
  1315. int            trap_Key_GetCatcher            ( void );
  1316. void        trap_Key_SetCatcher            ( int catcher );
  1317. int            trap_Key_GetKey                ( const char *binding );
  1318.  
  1319. // RMG traps
  1320. void        trap_RMG_Init                ( int terrainID, const char *terrainInfo );
  1321.  
  1322.  
  1323. void trap_SnapVector( float *v );
  1324.  
  1325. qboolean    trap_GetEntityToken( char *buffer, int bufferSize );
  1326. qboolean    trap_R_inPVS( const vec3_t p1, const vec3_t p2 );
  1327.  
  1328. #define G2SURFACEFLAG_ISBOLT        0x00000001
  1329. #define G2SURFACEFLAG_OFF            0x00000002    // saves strcmp()ing for "_off" in surface names
  1330. #define G2SURFACEFLAG_SPARE0        0x00000004    // future-expansion fields, saves invalidating models if we add more
  1331. #define G2SURFACEFLAG_SPARE1        0x00000008    //   
  1332. #define G2SURFACEFLAG_SPARE2        0x00000010    // 
  1333. #define G2SURFACEFLAG_SPARE3        0x00000020    // 
  1334. #define G2SURFACEFLAG_SPARE4        0x00000040    // 
  1335. #define G2SURFACEFLAG_SPARE5        0x00000080    // 
  1336. //
  1337. #define G2SURFACEFLAG_NODESCENDANTS 0x00000100    // ingame-stuff, never generated by Carcass....
  1338. #define G2SURFACEFLAG_GENERATED        0x00000200    //
  1339.  
  1340.  
  1341. void        trap_G2API_CollisionDetect        ( CollisionRecord_t *collRecMap, void* ghoul2, const vec3_t angles, const vec3_t position,int frameNumber, int entNum, const vec3_t rayStart, const vec3_t rayEnd, const vec3_t scale, int traceFlags, int useLod );
  1342.  
  1343.  
  1344. // CG specific API access
  1345. void        trap_G2_ListModelSurfaces(void *ghlInfo);
  1346. void        trap_G2_ListModelBones(void *ghlInfo, int frame);
  1347. int            trap_G2API_AddBolt(void *ghoul2, const int modelIndex, const char *boneName);
  1348. void        trap_G2API_SetBoltInfo(void *ghoul2, int modelIndex, int boltInfo);
  1349. qboolean    trap_G2API_RemoveBolt(void *ghlInfo, const int modelIndex, const int index);
  1350. qboolean    trap_G2API_AttachG2Model(void *ghoul2From, int modelFrom, void *ghoul2To, int toBoltIndex, int toModel);
  1351. qboolean    trap_G2API_DetachG2Model(void *ghoul2, int modelIndex);
  1352. void        trap_G2_SetGhoul2ModelIndexes(void *ghoul2, qhandle_t *modelList, qhandle_t *skinList);
  1353. qboolean    trap_G2_HaveWeGhoul2Models(void *ghoul2);
  1354. qboolean    trap_G2API_GetBoltMatrix(void *ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix,
  1355.                                 const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale);
  1356. int            trap_G2API_InitGhoul2Model(void **ghoul2Ptr, const char *fileName, int modelIndex, qhandle_t customSkin,
  1357.                           qhandle_t customShader, int modelFlags, int lodBias);
  1358. qboolean    trap_G2API_GetAnimFileNameIndex (TGhoul2 ghoul2, qhandle_t modelIndex, const char* name );
  1359.  
  1360. int            trap_G2API_CopyGhoul2Instance(void *g2From, void *g2To, int modelIndex);
  1361. int            trap_G2API_CopySpecificGhoul2Model(void *g2From, int modelFrom, void *g2To, int modelTo);
  1362. void        trap_G2API_DuplicateGhoul2Instance(void *g2From, void **g2To);
  1363. qboolean    trap_G2API_RemoveGhoul2Model(void **ghlInfo, int modelIndex);
  1364. void        trap_G2API_CleanGhoul2Models(void **ghoul2Ptr);
  1365.  
  1366. qboolean    trap_G2API_SetBoneAngles(void *ghoul2, int modelIndex, const char *boneName, const vec3_t angles, const int flags,
  1367.                                 const int up, const int right, const int forward, qhandle_t *modelList,
  1368.                                 int blendTime , int currentTime );
  1369. char        *trap_G2API_GetGLAName(void *ghoul2, int modelIndex);
  1370.  
  1371. qboolean    trap_G2API_SetBoneAnim( void *ghoul2, const int modelIndex, const char *boneName, const int startFrame, const int endFrame,
  1372.                                     const int flags, const float animSpeed, const int currentTime, const float setFrame , const int blendTime );
  1373. qboolean    trap_G2API_GetBoneAnim( void *ghoul2, const int modelIndex, const char *boneName, const int currentTime, float* frame );
  1374.  
  1375. qboolean    trap_G2API_SetSurfaceOnOff(void *ghoul2, const int modelIndex, const char *surfaceName, const int flags);
  1376. qboolean    trap_G2API_SetRootSurface(void **ghoul2, const int modelIndex, const char *surfaceName);
  1377. qboolean    trap_G2API_SetNewOrigin(void *ghoul2, const int modelIndex, const int boltIndex);
  1378. void        trap_G2API_AddSkinGore(void *ghlInfo,SSkinGoreData *gore);
  1379. void        trap_G2API_ClearSkinGore ( TGhoul2 ghoul2 );
  1380. qboolean    trap_G2API_SetGhoul2ModelFlags(void *ghlInfo,int flags);
  1381. int            trap_G2API_GetGhoul2ModelFlags(void *ghlInfo);
  1382. qboolean    trap_G2API_SetGhoul2ModelFlagsByIndex(void *ghoul2,int index,int flags);
  1383. int            trap_G2API_GetGhoul2ModelFlagsByIndex(void *ghoul2,int index);
  1384. int            trap_G2API_GetNumModels(TGhoul2 ghoul2);
  1385. int            trap_G2API_FindBoltIndex(TGhoul2 ghoul2, const int modelIndex, const char *boneName);
  1386. int            trap_G2API_GetBoltIndex(TGhoul2 ghoul2, const int modelIndex);
  1387.  
  1388. qhandle_t    trap_G2API_RegisterSkin ( const char *skinName, int numPairs, const char *skinPairs);
  1389. qboolean    trap_G2API_SetSkin        ( TGhoul2 ghoul2, int modelIndex, qhandle_t customSkin);
  1390.  
  1391. void        trap_MAT_Init(void);
  1392. void        trap_MAT_Reset(void);
  1393. sfxHandle_t trap_MAT_GetSound(char *key, int material);
  1394. qhandle_t    trap_MAT_GetDecal(char *key, int material);
  1395. const float trap_MAT_GetDecalScale(char *key, int material);
  1396. qhandle_t    trap_MAT_GetEffect(char *key, int material);
  1397. qhandle_t    trap_MAT_GetDebris(char *key, int material);
  1398. const float trap_MAT_GetDebrisScale(char *key, int material);
  1399.  
  1400. #define MAT_FOOTSTEP_NORMAL        "footstep"
  1401. #define MAT_FOOTSTEP_STEALTH    "footstepStealth"
  1402. #define MAT_FOOTSTEP_PRONE        "footstepProne"
  1403. #define MAT_AMMO_556            "5.56mm"
  1404. #define MAT_AMMO_9              "9mm"
  1405. #define MAT_AMMO_12             "12 gauge"
  1406. #define MAT_AMMO_045            "0.45 ACP"
  1407. #define MAT_AMMO_762            "7.62mm belt"
  1408. #define MAT_AMMO_127            "12.7mm"
  1409. #define MAT_LAND_NORMAL            "land"
  1410. #define MAT_LAND_PAIN            "land_pain"
  1411. #define MAT_LAND_DEATH            "land_death"
  1412. #define MAT_BOUNCEMETAL_1        "bouncemetal0"
  1413. #define MAT_BOUNCEMETAL_2        "bouncemetal1"
  1414.  
  1415.  
  1416. void        trap_CM_TM_Create(int terrainID);
  1417. void        trap_CM_TM_AddBuilding(int x, int y, int side);
  1418. void        trap_CM_TM_AddSpot(int x, int y);
  1419. void        trap_CM_TM_AddTarget(int x, int y, float radius);
  1420. void        trap_CM_TM_Upload(const vec3_t origin, const vec3_t angle);
  1421. void        trap_CM_TM_ConvertPosition(void);
  1422.  
  1423. int            trap_CM_RegisterTerrain(const char *config);
  1424. void        trap_RE_InitRendererTerrain( const char *info );
  1425. void        trap_CG_RegisterSharedMemory(char *memory);
  1426.  
  1427. // Memory allocation (note this memory is allocated from cgames vm hunk)
  1428. void*        trap_VM_LocalAlloc                ( int size );
  1429. void*        trap_VM_LocalAllocUnaligned        ( int size );            // WARNING!!!! USE WITH CAUTION!!! BEWARE OF DOG!!!
  1430. void*        trap_VM_LocalTempAlloc            ( int size );
  1431. void        trap_VM_LocalTempFree            ( int size );            // free must be in opposite order of allocation!
  1432. const char*    trap_VM_LocalStringAlloc        ( const char *source );
  1433.  
  1434. // Direct communication with the UI module
  1435. void        trap_UI_CloseAll                ( void );
  1436. void        trap_UI_SetActiveMenu            ( int menu );
  1437.  
  1438.  
  1439. void        CG_Init_CG(void);
  1440. void        CG_Init_CGents(void);
  1441.  
  1442.  
  1443. void CG_SetGhoul2Info( refEntity_t *ent, centity_t *cent);
  1444. void CG_AddProcGore(centity_t *cent);
  1445. void CG_PredictedProcGore ( int weaponnum, int attack, vec3_t start, vec3_t end, centity_t* cent );
  1446.  
  1447. qboolean G2_PositionEntityOnBolt(refEntity_t *ent, 
  1448.                              void *ghoul2, int modelIndex, int boltIndex, 
  1449.                              vec3_t origin, vec3_t angles, vec3_t modelScale);
  1450.  
  1451.  
  1452. void        CG_MiscEnt                ( void );
  1453. void        CG_DrawMiscEnts            ( void );
  1454. qboolean    CG_ParseGametypeFile    ( void );
  1455.  
  1456.